/*
 * app_mutilslot.h
 *
 *  Created on: 2023年7月18日
 *      Author: zlw
 */

#ifndef DS_APP_INS_APP_MULTISLOT_H_
#define DS_APP_INS_APP_MULTISLOT_H_

#include "stdint.h"
#include "stddef.h"

#define SLOT_ID   0

typedef enum {
    OTA_NoError    = 0x00,
    OTA_SlotError  = 0x81,
    OTA_SizeError  = 0x82,
    OTA_WriteError = 0x83,
    OTA_EraseError = 0x84
} OTAErrorCodes_t;

void ds_device_init_nvic(void);
void app_bootloader_init(void);
int32_t get_slot_info(void);
int32_t verify_application(void);
void erase_slot_if_needed(void);
void read_data_from_slot(uint32_t offset, uint8_t *buffer, size_t length);
void write_data_to_slot(uint32_t offset, uint8_t *buffer, size_t length);
void app_install_and_reboot(void);

#endif /* DS_APP_INS_APP_MULTISLOT_H_ */
